/*
 * @Author: chunlai
 * @Date: 2023-12-07 08:51:58
 * @LastEditTime: 2025-11-26 11:17:59
 * @LastEditors: minsheng_insurance_agency_zhoucl
 * @FilePath: \01.latest-short-insure\src\router\index.js
 * @Description: 
 */
import Vue from "vue";
import Router from "vue-router";
import store from "../store/index";

Vue.use(Router);
// 首页
const index = (resolve) => require(["@/views/index/index"], resolve);
// 首页--->海报网销
const poster = (resolve) => require(["@/views/poster/index.vue"], resolve);
// 首页--->全国级销售
const salesman = (resolve) =>
  require(["@/views/multipages/salesman.vue"], resolve);

const iframe_page = (resolve) =>
  require(["@/views/multipages/iframe.vue"], resolve);

const que_page = (resolve) =>
  require(["@/views/multipages/netques.vue"], resolve);

// 用户信息填写
const form = (resolve) => require(["@/views/form/index"], resolve);
// 投保计划(保费试算)
const plan = (resolve) => require(["@/views/form/plan"], resolve);

// 订单确认+签名页面
const sign_bill = (resolve) => require(["@/views/sign/bill.vue"], resolve);
// 影像件
// const image_files = (resolve) => require(['@/views/upload/files.vue'], resolve);

// 续保
const renewalins = (resolve) => require(["@/renewal/index.vue"], resolve);

/*文档阅读*/
const read = (resolve) => require(["@/views/read/index.vue"], resolve);
const assess = (resolve) => require(["@/views/assess/index.vue"], resolve);

/*支付*/
// const pay_index = (resolve) => require(['@/views/pay/index.vue'], resolve);
/* ===== 银行卡 ===== */
// const contract = (resolve) =>
//   require(['@/views/bankcard/contract.vue'], resolve);
// const replace = (resolve) => require(['@/views/bankcard/replace.vue'], resolve);

// 分享签名页
// const newsign = (resolve) => require(['@/views/sign/preact.vue'], resolve);

/* ===== 操作结果状态页 ===== */
const billres = (resolve) => require(["@/views/result/bill.vue"], resolve);
const shareres = (resolve) => require(["@/views/result/share.vue"], resolve);

const router = new Router({
  routes: [
    {
      path: "/",
      redirect: "/index",
    },
    {
      path: "/index",
      name: "Index",
      component: index,
      meta: {
        title: "", // 缓存首页
        keepAlive: true,
      },
    },
    {
      path: "/renewal",
      name: "RenewalPage",
      component: renewalins,
      meta: {
        title: "",
      },
    },
    {
      path: "/poster",
      name: "poster",
      component: poster,
      meta: {
        title: "产品海报", // 缓存首页
        keepAlive: true,
      },
    },
    {
      path: "/salesman",
      name: "salesman",
      component: salesman,
      meta: {
        title: "出单员", // 缓存首页
        keepAlive: true,
      },
    },
    {
      path: "/iframe",
      name: "IframePage",
      component: iframe_page,
      meta: {
        title: "智能核保",
      },
    },
    {
      path: "/ques",
      name: "NetQuePage",
      component: que_page,
      meta: {
        title: "互联网保险适当性评估问卷",
      },
    },
    {
      path: "/form",
      name: "form",
      component: form,
      meta: {
        title: "投保页面",
        keepAlive: false,
      },
    },
    {
      path: "/plan",
      name: "plan",
      component: plan,
      meta: {
        title: "投保计划",
        keepAlive: false,
      },
    },

    // {
    //   path: '/files',
    //   name: 'files',
    //   meta: {
    //     title: '影像件资料',
    //   },
    //   component: image_files,
    // },
    {
      // 订单详情
      path: "/billsure",
      name: "billSurePage",
      component: sign_bill,
      meta: {
        title: "订单确认页",
      },
    },
    // 文件阅读
    {
      path: "/read",
      name: "ReadPage",
      component: read,
      meta: {
        title: "条款详情",
      },
    },
    // {
    //   path: '/pay',
    //   name: 'PaymentPage',
    //   component: pay_index,
    //   meta: {
    //     title: '支付确认',
    //   },
    // },

    /* ===== 最新投保页(2023-7-25) ===== */
    // {
    //   path: '/newsign',
    //   name: 'SignBeforeSurePage',
    //   component: newsign,
    //   meta: {
    //     title: '授权与须知签名',
    //   },
    // },
    // {
    //   path: '/replace',
    //   name: 'BankcardReplacePage',
    //   component: replace,
    //   meta: {
    //     title: '更换银行卡',
    //   },
    // },
    // {
    //   path: '/contract',
    //   name: 'BankcardContractPage',
    //   component: contract,
    //   meta: {
    //     title: '签约',
    //   },
    // },
    {
      path: "/shareres",
      name: "ShareResultPage",
      meta: {
        title: "结果页",
      },
      component: shareres,
    },
    {
      path: "/billres",
      name: "BillResultPage",
      meta: {
        title: "投保结果",
      },
      component: billres,
    },
    {
      path: "/assess",
      name: "AssessPage",
      meta: {
        title: "",
      },
      component: assess,
    },
    {
      path: "*",
      component: () => import("@/components/NotFound"),
    },
    // {
    //   path: "/test_page",
    //   name: "NewCopmTest",
    //   component: () => import("@/views/test/index.vue"),
    //   meta: {
    //     title: "新功能组件测试",
    //   },
    // },
  ],
});

router.beforeEach((to, from, next) => {
  let { title } = to.meta;
  document.title = title || store.state.varietyInfo.productName;
  next();
});

export default router;
